/*----------------------------------------------------------------------------
 * osObjects.h: CMSIS-RTOS global object definitions for an application
 *----------------------------------------------------------------------------
 *
 * This header file defines global RTOS objects used throughout a project
 *
 * #define osObjectsPublic indicates that objects are defined; without that
 * definition the objects are defined as external symbols.
 *
 *--------------------------------------------------------------------------*/


#ifndef __osObjects
#define __osObjects

#if (!defined (osObjectsPublic))
#define osObjectsExternal           // define RTOS objects with extern attribute
#endif

#ifdef osObjectsPublic
#define OBJ_EXT  
#else
#define OBJ_EXT extern 
#endif

#include "cmsis_os.h"               // CMSIS RTOS header file


// global 'thread' functions ---------------------------------------------------
/* 
Example:
extern void sample_name (void const *argument);         // thread function

osThreadId tid_sample_name;                             // thread id
osThreadDef (sample_name, osPriorityNormal, 1, 0);      // thread object
*/
int Init_Thread (void);
int Init_Mutex (void);


void ComTask (void const *argument);                             // thread function
OBJ_EXT osThreadId tid_ComTask;                                  // thread id
osThreadDef (ComTask, osPriorityNormal, 1, 0);                   // thread object

/*
void WifiTask (void const *argument);                            // thread function
OBJ_EXT osThreadId tid_WifiTask;                                 // thread id
osThreadDef (WifiTask, osPriorityAboveNormal, 1, 0);             // thread object
*/
void Modbus (void const *argument);                              // thread function
OBJ_EXT osThreadId tid_Modbus;                                   // thread id
osThreadDef (Modbus, osPriorityAboveNormal, 1, 0);               // thread object

void PrintTask (void const *argument);                           // thread function
OBJ_EXT osThreadId tid_PrintTask;                                // thread id
osThreadDef (PrintTask, osPriorityBelowNormal, 1, 0);            // thread object

void Thread (void const *argument);                           // thread function
OBJ_EXT osThreadId tid_Thread;                                // thread id
osThreadDef (Thread, osPriorityBelowNormal, 1, 0);            // thread object

// global 'semaphores' ----------------------------------------------------------
/* 
Example:
osSemaphoreId sid_sample_name;                          // semaphore id
osSemaphoreDef (sample_name);                           // semaphore object
*/

// global 'mutex' ----------------------------------------------------------
OBJ_EXT osMutexId mid_I2cMutex;                                  // mutex id
osMutexDef (I2cMutex);                                           // mutex name definition

OBJ_EXT osMutexId mid_TimeMutex;                                  // mutex id , protect TimeCur
osMutexDef (TimeMutex);                                           // mutex name definition

// global 'memory pools' --------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osPoolId mpid_sample_name;                              // memory pool id
osPoolDef (sample_name, 16, type_sample_name);          // memory pool object
*/


// global 'message queues' -------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osMessageQId mid_sample_name;                           // message queue id
osMessageQDef (sample_name, 16, type_sample_name);      // message queue object
*/


// global 'mail queues' ----------------------------------------------------------
/* 
Example:
typedef struct sample_name type_sample_name;            // object data type

osMailQId qid_sample_name;                              // mail queue id
osMailQDef (sample_name, 16, type_sample_name);         // mail queue object
*/

#endif  // __osObjects
